<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.printeverywhere.dto.User"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<s:form method="post" action="showAccountsManager"
	namespace="/admin" theme="simple">
	<table class="verdana12blacknormal" width="100%">
		<tbody>
			<tr>
				<td height="40" class="sectionheading bottom-border">
					Accounts Manager
				</td>
			</tr>
			<tr>
				<td>
					<table width="100%">
					<tr>
					<td class="verdana12blacknormal">
								<s:actionerror cssClass="Note-red"/>
								<s:fielderror cssClass="Note-red"/>
								<s:actionmessage cssClass="Note-red"/>
							</td>
							</tr>
						<tr align="left">
							<td class="verdana12blacknormal">
								Search for:
							</td>
							<td nowrap="nowrap" class="verdana12blacknormal">
								<s:textfield name="searchString" theme="simple"
									cssClass="Textfiled-border" />
							</td>
							<td nowrap="nowrap" class="verdana12blacknormal">
								<s:select list="accountSearchList" name="criteria"
									theme="simple" listKey="key" listValue="value"
									cssClass="Textfiled-border" />
							</td>
							<td class="verdana12blacknormal">
							<s:hidden name="operation" value="Search"></s:hidden>
								<s:submit type="image"
									src="../Admin-Images/search-btn.gif" theme="simple"
									title="Search" />

							</td>
						</tr>
						<tr>
							<td class="verdana12blacknormal">
								Region/Country
							</td>
							<td class="verdana12blacknormal">
								<s:doubleselect name="regionSearch" list="%{#attr.regionList}"
									listKey="categoryId" listValue="categoryName" theme="simple"
									headerKey="-1" headerValue="----------Region ----------"
									doubleName="countrySearch" doubleList="%{#attr.countryList}"
									doubleListKey="categoryId" doubleListValue="categoryName"
									doubleHeaderValue="----------Country ----------"
									doubleHeaderKey="-1" cssClass="Textfiled-border" doubleCssStyle="Textfiled-border"
									doubleCssClass="Textfiled-border">
								</s:doubleselect>
							</td>
						</tr>
						<tr>
							<td class="verdana12blacknormal">
								Balance From
								Euro:
							</td>
							<td colspan="2" class="verdana12blacknormal">
								<s:textfield name="balanceEuroFrom" theme="simple"
									cssClass="Textfiled-border" />
								To Euro
								<s:textfield name="balanceEuroTo" theme="simple"
									cssClass="Textfiled-border" />
							</td>
						</tr>
						<tr>
							<td class="verdana12blacknormal">
								Spent From Euro:
							</td>
							<td colspan="2" class="verdana12blacknormal">
								<s:textfield name="spentEuroFrom" theme="simple"
									cssClass="Textfiled-border" />
								<s:text name="label.system.toEuro" />
								<s:textfield name="spentEuroTo" theme="simple"
									cssClass="Textfiled-border" />
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</tbody>

	</table>

	<s:hidden name="pageSize" value="%{pageSize}" id="pageSize" />

	<span class="verdana12blacknormal"> <s:text
			name="Accounts" />
	</span>

	<table class="verdana12blacknormal" width="100%" cellpadding="0"
		cellspacing="1">
		<tr>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">A</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">
					<b>A(<s:text name="userAccountsCount.aa"></s:text>)</b>
				</s:a>
			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">B</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>B(<s:text name="userAccountsCount.bb"></s:text>) </b>
				</s:a>
			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">C</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>C(<s:text name="userAccountsCount.cc"></s:text>) </b>
				</s:a>
			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">D</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>D(<s:text name="userAccountsCount.dd"></s:text>) </b>
				</s:a>

			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">E</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>E(<s:text name="userAccountsCount.ee"></s:text>) </b>
				</s:a>

			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">F</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>F(<s:text name="userAccountsCount.ff"></s:text>) </b>
				</s:a>
			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">G</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>G(<s:text name="userAccountsCount.gg"></s:text>) </b>
				</s:a>
			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">H</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>H(<s:text name="userAccountsCount.hh"></s:text>) </b>
				</s:a>
			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">I</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>I(<s:text name="userAccountsCount.ii"></s:text>) </b>
				</s:a>
			</td>
		</tr>
		<tr>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">J</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>J(<s:text name="userAccountsCount.jj"></s:text>) </b>
				</s:a>
			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">K</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>K(<s:text name="userAccountsCount.kk"></s:text>) </b>
				</s:a>
			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">L</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>L(<s:text name="userAccountsCount.ll"></s:text>) </b>
				</s:a>
			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">M</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>M(<s:text name="userAccountsCount.mm"></s:text>) </b>
				</s:a>
			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">N</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>N(<s:text name="userAccountsCount.nn"></s:text>) </b>
				</s:a>
			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">O</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>O(<s:text name="userAccountsCount.oo"></s:text>) </b>
				</s:a>
			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">P</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>P(<s:text name="userAccountsCount.pp"></s:text>) </b>
				</s:a>
			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">Q</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>Q(<s:text name="userAccountsCount.qq"></s:text>) </b>
				</s:a>
			</td>
			<td align="left" valign="top" width="10%">
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">R</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>R(<s:text name="userAccountsCount.rr"></s:text>) </b>
				</s:a>
			</td>
		</tr>
		<tr>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">S</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>S(<s:text name="userAccountsCount.ss"></s:text>) </b>
				</s:a>
			</td>
			<td align="left" valign="top" width="10%">
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">T</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>T(<s:text name="userAccountsCount.tt"></s:text>) </b>
				</s:a>
			</td>
			<td align="left" valign="top" width="10%">
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">U</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>U(<s:text name="userAccountsCount.uu"></s:text>) </b>
				</s:a>
			</td>
			<td align="left" valign="top" width="10%">
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">V</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>V(<s:text name="userAccountsCount.vv"></s:text>) </b>
				</s:a>
			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">W</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>W(<s:text name="userAccountsCount.ww"></s:text>) </b>
				</s:a>
			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">X</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>X(<s:text name="userAccountsCount.xx"></s:text>) </b>
				</s:a>
			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">Y</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>Y(<s:text name="userAccountsCount.yy"></s:text>) </b>
				</s:a>
			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">Z</s:param>
				</s:url>
				<s:a href="%{groupurl}" cssClass="navi-link">

					<b>Z(<s:text name="userAccountsCount.zz"></s:text>) </b>
				</s:a>
			</td>
			<td>
				<s:url action="showAccountsManager.htm" var="groupurl">
					<s:param name="group">Other</s:param>
				</s:url>
				<s:a href="showOwnerDetails.htm" cssClass="navi-link">
					<b>#(<s:text name="userAccountsCount.other"></s:text>)</b>
				</s:a>
			</td>
		</tr>
	</table>
</s:form>
<s:form method="post" action="showAccountsManager" id="form"
	namespace="/admin" theme="simple">
	<s:set var="pageSize" value="%{pageSize}" />
	<display:table name="list" pagesize="${pageSize}" cellpadding="0"
		cellspacing="0" requestURI="showAccountsManager.htm" id="row"
		class="verdana12blacknormal">
		<display:column title="#" headerClass="Table-Head">
			<c:out value="${row_rowNum}" />
		</display:column>
		<display:column headerClass="Table-Head" property="userId" title="Account" autolink="true" href="accountDetails.htm" paramId="accountDetailid" paramProperty="id" class="navi-link" />
		<display:column headerClass="Table-Head"
			autolink="true" title="Balance" class="navi-link">
			Euro <%=((User) row).getCurrentBalance()%>
		</display:column>
		<display:column headerClass="Table-Head" property="email"
			autolink="true" titleKey="label.system.Email" class="navi-link" />

		<display:column headerClass="Table-Head"
						title="Manage"
						 class="navi-link">

						 <s:url action="editUser" namespace="/ajax" var="edit">
						 	<s:param name="userId" value="%{#attr.row.id}" />
						 	<s:param name="adminaction" value="showAccountsManager" />
						 </s:url>
						<s:a href="javascript:PPPCC=window.open('%{edit}','Edit User Information','scrollbars=yes,resizable=false');PPPCC.focus()" cssClass="navi-link">
							Manage
						</s:a>
					</display:column>
		<display:column headerClass="Table-Head" title="Delete">
			<input type="checkbox" id="delete" name="selectedUserDeleted" value="<%=((User) row).getId()%>">
		</display:column>
		<display:column headerClass="Table-Head" title="Status">
			<input type="checkbox" id="status"  name="userMap[<%=((User) row).getId()%>].active" value="true" <%=((User) row).getActive() == true ? "checked" : ""%>>
			<input type="hidden" name="userMap[<%=((User) row).getId()%>].id" value="<%=((User) row).getId()%>">
			<input type="hidden" name="userMapFlag[<%=((User) row).getId()%>].active" value="<%=((User) row).getActive()%>">
			<input type="hidden" name="userMapFlag[<%=((User) row).getId()%>].id" value="<%=((User) row).getId()%>">
		</display:column>
	</display:table>



	<table class="verdana12blacknormal" width="100%">
		<tr>
			<td>
				<img style="cursor: pointer;"
					onclick="javascript:checkAllD(document.form.selectedUserDeleted)"
					src="../Admin-Images/check-all-delete-btn.gif"
					alt="Check All Delete" title="Check All Delete">

				<img style="cursor: pointer;"
					onclick="javascript:uncheckAllD(document.form.selectedUserDeleted)"
					src="../Admin-Images/un-check-all-delete-btn.gif"
					alt="Uncheck All Delete" title="Uncheck All Delete">

				<img style="cursor: pointer;"
					onclick="javascript:checkall('form','status',true)"
					src="../Admin-Images/check-all-states-btn.gif"
					alt="Check All Status" title="Check All Status">
				<img style="cursor: pointer;"
					onclick="javascript:checkall('form','status',false)"
					src="../Admin-Images/un-check-all-states-btn.gif"
					alt="UnCheck All Status" title="UnCheck All Status">

			</td>
		</tr>
		<tr>
			<td>
				<br>
				<s:hidden name="operation" value="Submit"></s:hidden>
				<s:submit type="image"
					src="../Admin-Images/submit-btn.gif" theme="simple" title="Submit" />
				<img style="cursor: pointer;"
					onclick="document.getElementById('form').reset();"
					src="../Admin-Images/reset-button.gif" alt="Reset" title="Reset">
				Page size: <s:select value="%{pageSize}" name="pageSize" theme="simple" list="#{'10':'10', '20':'20', '50':'50', '100':'100'}" onchange="document.getElementById('pageSize').value = this.value;document.forms[0].submit();" />
			</td>
		</tr>
	</table>

</s:form>

<script>
function checkall(formname,checkname,thestate){
var el_collection=eval("document.forms."+formname+"."+checkname)
for (c=0;c<el_collection.length;c++)
el_collection[c].checked=thestate
}

function checkAllD(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

function uncheckAllD(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}

</script>
